package cn.tedu.ivos.vehicle.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.vehicle.pojo.dto.RepairVehicleQuery;
import cn.tedu.ivos.vehicle.pojo.dto.RepairVehicleSaveParam;
import cn.tedu.ivos.vehicle.pojo.vo.RepairVehicleVO;
import cn.tedu.ivos.vehicle.service.RepairVehicleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author liyuehui
 * @time 2024/7/31 14:42
 */
@Slf4j
@Api(tags = "维修车辆管理接口")
@RestController
@RequestMapping("/v1/repairVehicle/")
public class RepairVehicleController {
    @Autowired
    RepairVehicleService repairVehicleService;

    @GetMapping("select")
    @ApiOperation("查询维修车辆信息")
    public JsonResult select(RepairVehicleQuery repairVehicleQuery) {
        log.debug("查询维修车辆信息,repairVehicleQuery={}", repairVehicleQuery);
        List<RepairVehicleVO> list = repairVehicleService.select(repairVehicleQuery);
        log.debug("查询到" + list.size() + "条维修车辆业务信息");
        return JsonResult.ok(list);
    }

    @PostMapping("save")
    @ApiOperation("保存维修车辆信息")
    public JsonResult save(RepairVehicleSaveParam repairVehicleSaveParam) {
        log.debug("保存维修车辆信息,repairVehicleSaveParam={}", repairVehicleSaveParam);
        repairVehicleService.save(repairVehicleSaveParam);
        return JsonResult.ok();
    }

    @PostMapping("delete/{id}")
    @ApiOperation("删除维修车辆信息")
    public JsonResult delete(@PathVariable Long id) {
        log.debug("删除维修车辆信息,id={}", id);
        repairVehicleService.delete(id);
        return JsonResult.ok();
    }
}
